<template>
    <el-row :gutter="0">
        <el-col :span="24" style="margin-top:15px;" v-if="path.consumes && path.consumes.length > 0">
            <i class="el-icon-info"></i> <span style="line-height: 28px; font-weight: bold;">Request Content-Type：</span>
            <span>{{path.consumes.join(' | ')}}</span>
        </el-col>
        <el-col :span="24" v-if="path.parameters !== undefined && path.parameters !== null && path.parameters.length > 0" style="margin-top:5px;">
            <i class="el-icon-s-grid"></i> <span style="line-height: 28px; font-weight: bold;">Request Parameters：</span>
        </el-col>
        <el-col :span="24" v-if="path.parameters !== undefined && path.parameters !== null && path.parameters.length > 0" style="margin-top:5px;">
            <el-table :data="path.parameters" size="mini" :row-key="rowKey" :expand-row-keys="path.expandParameters" :row-class-name="expandClass">
                <el-table-column label="Name" prop="name" width="180"></el-table-column>
                <el-table-column label="ParameterType" prop="in" width="180"></el-table-column>
                <el-table-column label="Required" :formatter="formatRequired" width="180"></el-table-column>
                <el-table-column label="DataType" :formatter="formatDataType" width="180"></el-table-column>
                <el-table-column label="Description" prop="description"></el-table-column>
                <el-table-column type="expand">
                    <template slot-scope="props" v-if="path.expandParameters.indexOf(props.row.name) >= 0">
                        <el-row :gutter="20">
                            <el-col :span="12">Model：</el-col>
                            <el-col :span="12">Example：</el-col>
                            <el-col :span="12">
                                <el-input type="textarea" :autosize="{ maxRows: 10 }" :value="getModel(props.row.schema)"></el-input>
                            </el-col>
                            <el-col :span="12">
                                <el-input type="textarea" :autosize="{ maxRows: 10 }" :value="getExample(props.row.schema)"></el-input>
                            </el-col>
                        </el-row>
                    </template>
                </el-table-column>
            </el-table>
        </el-col>
    </el-row>
</template>

<script>
  export default {
    name: "parameters",
    props: ['path'],
    inject: [
      'rowKey',
      'expandClass',
      'formatRequired',
      'formatDataType',
      'getModel',
      'getExample'
    ]
  }
</script>

<style scoped>

</style>